package org.example.onlinechat.mapper;

import com.volcengine.ark.runtime.model.completion.chat.ChatMessage;
import org.apache.ibatis.annotations.*;
import org.example.onlinechat.entity.OrdMsg;
import org.example.onlinechat.entity.SystemData;

import java.util.List;

@Mapper
public interface ChatMapper {

    @Insert("INSERT INTO msg (msgData,user_id) VALUES (#{json},#{user_id})")
    void insert(String user_id, String json);


    @Select("select msgData from msg where user_id=#{user_id}")
    String selectData(int user_id);

    @Update("UPDATE msg SET user_id = #{userId}, msgData = #{json} WHERE user_id = #{userId}")
    void UpdataChat(String userId, String json);

    @Insert("INSERT INTO ordermsg (msgData,user_id) VALUES (#{data},#{userId})")
    void insertOChat(int userId, String data);

    @Delete("DELETE FROM msg WHERE user_id = #{user_id}")
    void delete(int user_id);

    @Select("select * from ordermsg where user_id=#{user_id}")
    List<OrdMsg> selectOrdData(int user_id);

    @Select("select msgData from ordermsg where user_id=#{user_id} and omsgID=#{omsgID}")
    String chatSelectOrdN(OrdMsg msg);


    @Select("SELECT\n" +
            "\tordermsg.msgData\n" +
            "FROM\n" +
            "\tordermsg\n" +
            "WHERE\n" +
            "\tordermsg.user_id = 1")
    List<OrdMsg> selectAllOrdData();
}
